package cn.always.xiajia.admin.client.api.sys.dto;

import java.util.List;
import java.util.Set;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Schema(description = "管理后台 - 登录用户的权限信息 Response VO，额外包括用户信息和角色列表")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AuthPermissionInfoRespVO {

	@Schema(description = "用户信息", requiredMode = Schema.RequiredMode.REQUIRED)
	private UserVO user;

	@Schema(description = "角色标识数组", requiredMode = Schema.RequiredMode.REQUIRED)
	private Set<String> roles;

	@Schema(description = "操作权限数组", requiredMode = Schema.RequiredMode.REQUIRED)
	private Set<String> permissions;

	@Schema(description = "菜单树", requiredMode = Schema.RequiredMode.REQUIRED)
	private List<MenuVO> menus;

	@Schema(description = "用户信息 VO")
	@Data
	@NoArgsConstructor
	@AllArgsConstructor
	@Builder
	public static class UserVO {

		@Schema(description = "用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
		private Long userId;

		@Schema(description = "用户编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "102411")
		private String userCode;

		@Schema(description = "用户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "xiajia")
		private String userName;

		@Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
		private String userType;

		@Schema(description = "邮箱", requiredMode = Schema.RequiredMode.AUTO, example = "xiajia@qq.com")
		private String email;

		@Schema(description = "手机", requiredMode = Schema.RequiredMode.AUTO, example = "15960572586")
		private String mobile;

		@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "男")
		protected String sex;

		@Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.jpg")
		private String avatar;

	}

	@Schema(description = "管理后台 - 登录用户的菜单信息 Response VO")
	@Data
	@NoArgsConstructor
	@AllArgsConstructor
	@Builder
	public static class MenuVO {

		@Schema(description = "菜单ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试")
		private Long menuId;

		@Schema(description = "父菜单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
		private Long parentId;

		@Schema(description = "菜单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "xx")
		private String name;

		@Schema(description = "菜单名称中文", requiredMode = Schema.RequiredMode.REQUIRED, example = "xx")
		private String nameZhCn;

		@Schema(description = "路由地址,仅菜单类型为菜单或者目录时，才需要传", example = "post")
		private String path;

		@Schema(description = "组件路径,仅菜单类型为菜单时，才需要传", example = "system/post/index")
		private String component;

		@Schema(description = "组件名", example = "SystemUser")
		private String componentName;

		@Schema(description = "菜单图标,仅菜单类型为菜单或者目录时，才需要传", example = "menu")
		private String icon;

		@Schema(description = "是否显示", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
		private Boolean visible;

		@Schema(description = "是否缓存", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
		private Boolean isCache;

		/**
		 * 子路由
		 */
		private List<MenuVO> children;

	}

}
